var Player = function(graph){
	var _this = this;
	this.graph = graph;
	this.stopCam = 0;
	this.startCam = 0;
	this.ticker;
	this.bPlay = $('#toggle');
	this.bTgl = function(){
		var icon = 'pause';
		if (video.paused) icon = 'play';
		this.bPlay.empty().append($("<i>").attr("class", "icon-"+icon));
	}
	this.lahutav;
	this.frames = VideoFrame({
		id:'video',
		frameRate: FrameRates.NTSC,
        callback : function(response) {
        }
	});
	$(video).bind("loadedmetadata", function (){
          video.play();
          video.pause();
    });
	$(video).bind("play", 
			function(){ _this.moveGraph();}
	);
	$(video).bind("seeking", 
			function (){
					_this.showCurFr();
					_this.graph.draw();
			});
	$(video).bind("ended", 
			function(){	_this.stopGraph();}
	);
	$(video).bind("pause", 
			function(){ _this.stopGraph();}
	);
	this.moveGraph = function(){
		this.bTgl();
		if (video.ended) stopGraph;
		if (video.paused) return;
	    _this.ticker = setInterval(
	    		function updPlot(){
	    			if (video.currentTime >0) _this.showCurFr();
	        		graph.draw();
	        		},
	         33);
    }
	this.stopGraph = function(){
		this.bTgl();
		graph.draw();
		clearInterval(_this.ticker);
	}
	this.stop = function(){
		video.currentTime = 0;
		video.pause();
		trig = true;
	}
	this.start = function(){
		this.bTgl();
		if (video.paused) video.play();
        else video.pause();
	}
	this.seek = function(frame, fw){
		if (!fw) fw = -1;
		this.frames.seekForward(frame*fw);
		this.showCurFr();
		graph.draw();
    }
   
    this.showCurFr = function(){
        var frame = this.frames.get();
        var SMPTE = this.frames.toSMPTE();
        $("#curFrame").text(frame+" ["+SMPTE+"]");
        var numb= graph.getType() == "lines" ? graph.pikkus/2 : 0;
    }
   
    
}
